<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="vue.min.js"></script>
</head>
<body>
<div id="app">
<p>{{fullName}}</p>
  firstName: <input type="text" v-model="firstName">
  lastName: <input type="text" v-model="lastName">
</div>
<script>
  var vm = new Vue({
    el: '#app',
    data:{
      firstName: 'Ffffoo',
      lastName: 'fsdffds',
      fullName: 'Foofs Bar'
    },
    // watch:{
    //   firstName: function (newVal, oldVal){
    //     this.fullName = newVal + ' ' + this.lastName;
    //   },
    //   lastName: function (newVal, oldVal) {
    //     this.fullName = this.firstName+' ' +newVal
    //   }
    // },
    computed: {
      // fullName: function () {
      //   return this.firstName + ' ' + this.lastName;
      // }
      fullName: {
        get: function (){
          return this.firstName + ' ' + this.lastName;
        },
        set: function (newValue) {
          var names = newValue.split(' ')
          this.firstName = names[0]
          this.lastName = names[names.length - 1]
        }
      }
    },
    methods: {

    }
  })
</script>
</body>
</html>